home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / aminet / os20 / cdity / huntwin4.lha / huntwindows.s < prev   
Text File  |  1993-03-31  |  35KB  |  1,686 lines

  1.              output    work:huntwindows
  2.             OPT o+,ow-
  3.             ;no includes - i use them all preassembled!
  4.  
  5.             ;.... nearly all ....
  6.  
  7.             incdir    "sys:devpac/include/"
  8.             include "workbench/startup.i"
  9.             include "workbench/workbench.i"
  10.             include    "workbench/icon_lib.i"
  11.             include    "libraries/commodities.i"
  12.  
  13. ;TODO:
  14. ;Hotkey for GUI
  15.  
  16. ;BUGS:
  17. ;SOMETIMES... there is a guru at closedown
  18.     
  19.             ;Some helpful macros
  20. CALL            macro
  21.             jsr    _LVO\1(a6)
  22.             endm
  23. Push            macro
  24.             movem.l    \1,-(sp)
  25.             endm
  26. Pull            macro
  27.             movem.l    (sp)+,\1
  28.             endm
  29. RSave            macro
  30.             movem.l    a0-a6/d0-d7,-(sp)
  31.             endm
  32. RLoad            macro
  33.             movem.l    (sp)+,a0-a6/d0-d7
  34.             endm
  35.  
  36. MaxScreens        equ    64    ;Maximum of 64 Screens - who has more?
  37. ScreenMemSize        equ    MaxScreens*8    
  38.  
  39.         ;Bits for Communication
  40. SignalWindow        equ    0
  41. SignalScreen        equ    1
  42.  
  43.             RSave
  44.  
  45.             move.l    $04,a6
  46.             move.l    #AllocLength,d0
  47.             move.l    #MEMF_CLEAR,d1
  48.             CALL    AllocMem
  49.             move.l    d0,a4
  50.             tst.l    d0
  51.             beq    EndeRaus
  52.  
  53.             move.l    d0,RememberA4
  54.             move.l    a7,RememberStack
  55.  
  56.             lea    intuition(pc),a1
  57.             moveq.l    #36,d0
  58.             CALL    OpenLibrary
  59.             move.l    d0,IntBase(a4)
  60.             beq    EndeRaus2
  61.  
  62.             lea    DosName(pc),a1
  63.             moveq.l    #36,d0
  64.             CALL    OpenLibrary    
  65.             move.l    d0,DosBase(a4)
  66.             beq    Error2
  67.  
  68.             lea    GadName(pc),a1
  69.             moveq.l    #0,d0
  70.             CALL    OpenLibrary
  71.             move.l    d0,GadBase(a4)
  72.             beq    Error2
  73.  
  74.             lea    CommName(pc),a1
  75.             moveq.l    #0,d0
  76.             CALL    OpenLibrary
  77.             move.l    d0,CommBase(a4)
  78.             beq    Error2
  79.  
  80.             CALL    CreateMsgPort
  81.             move.l    d0,MouseMsgPort(a4)
  82.             beq    Error2
  83.  
  84.             move.l    #SIGBREAKF_CTRL_C,SignalMask(a4)
  85.  
  86.             move.l    d0,a0
  87.             move.l    #IOSTD_SIZE,d0
  88.             CALL    CreateIORequest
  89.             move.l    d0,MyIORequest(a4)
  90.             beq    Error2
  91.  
  92.             lea    InputName(pc),a0
  93.             moveq.l    #0,d0
  94.             move.l    MyIORequest(a4),a1
  95.             moveq.l    #0,d1
  96.             CALL    OpenDevice
  97.             tst.l    d0
  98.             bne    Error2
  99.  
  100.             lea    IconName(pc),a1
  101.             moveq.l    #33,d0
  102.             CALL    OpenLibrary
  103.             move.l    d0,IconBase(a4)
  104.             beq    Error2
  105.  
  106.             move.l    ThisTask(a6),a1
  107.             move.l    a1,OwnTask(a4)
  108.             tst.l    pr_CLI(a1)
  109.             bne    CliStart
  110.             lea    pr_MsgPort(a1),a2
  111.             move.l    a2,a0
  112.             CALL    WaitPort
  113.             move.l    a2,a0
  114.             CALL    GetMsg
  115.             move.l    d0,WBMessage(a4)
  116.             move.l    d0,a3
  117.         
  118.             move.l    sm_ArgList(a3),d7
  119.             beq    DisableSave
  120.             move.l    d7,a0
  121.             move.l    wa_Lock(a0),d1
  122.             move.l    DosBase(a4),a6
  123.             CALL    CurrentDir
  124.  
  125.             move.l    IconBase(a4),a6
  126.             move.l    d7,a0
  127.             move.l    wa_Name(a0),a0
  128.             CALL    GetDiskObject
  129.             move.l    d0,DObject(a4)
  130.             beq    Error2
  131.  
  132.             lea    WBTemplate(pc),a3
  133.  
  134.             move.l    d0,a0
  135.             move.l    do_ToolTypes(a0),a0
  136.             
  137. GetEmLoop        tst.l    (a3)
  138.             beq.s    FreeDobj
  139.             move.l    TemplateText(a3),a1
  140.             beq.s    FreeDobj
  141.             move.l    a0,-(sp)
  142.             CALL    FindToolType
  143.             move.l    (sp)+,a0
  144.             sub.l    a2,a2
  145.             move.w    TemplateA4(a3),a2
  146.             add.l    a4,a2
  147.             move.l    d0,(a2)
  148.             add.l    #TemplateSize,a3
  149.             bra.s    GetEmLoop
  150.  
  151. FreeDobj        bsr    BuildPatterns
  152.  
  153.             bra.s    SkipReadArgs
  154.  
  155. CliStart        move.l    DosBase(a4),a6
  156.  
  157.             move.l    #Template,d1
  158.             lea    TemplateArray(a4),a0
  159.             move.l    a0,d2
  160.             moveq.l    #0,d3
  161.             CALL    ReadArgs    ;Get options
  162.             tst.l    d0
  163.             beq    Error2
  164.             move.l    d0,Args(a4)
  165.     
  166.             bsr    BuildPatterns
  167.  
  168. DisableSave        move.l    #1,TempSave(a4)
  169.  
  170. SkipReadArgs        move.l    $04,a6
  171.             lea    GraphicsName(pc),a1
  172.             moveq.l    #36,d0
  173.             CALL    OpenLibrary
  174.             move.l    d0,GraphicsBase(a4)
  175.             beq    Error2
  176.  
  177.             tst.l    TempHADJ(a4)
  178.             beq    GotIt1
  179.             move.l    TempHADJ(a4),a0
  180.             bsr    GetNexta0
  181.             clr.l    TempHADJ(a4)
  182.             cmp.b    #"l",d0
  183.             beq.s    GotIt1
  184.             add.l    #1,TempHADJ(a4)
  185.             cmp.b    #"r",d0
  186.             beq.s    GotIt1
  187.             add.l    #1,TempHADJ(a4)
  188.             cmp.b    #"c",d0
  189.             beq.s    GotIt1
  190.             add.l    #1,TempHADJ(a4)
  191.  
  192. GotIt1            tst.l    TempVADJ(a4)
  193.             beq    GotIt2
  194.             move.l    TempVADJ(a4),a0
  195.             bsr    GetNexta0
  196.             clr.l    TempVADJ(a4)
  197.             cmp.b    #"t",d0
  198.             beq.s    GotIt2
  199.             add.l    #1,TempVADJ(a4)
  200.             cmp.b    #"b",d0
  201.             beq.s    GotIt2
  202.             add.l    #1,TempVADJ(a4)
  203.             cmp.b    #"c",d0
  204.             beq.s    GotIt2
  205.             add.l    #1,TempVADJ(a4)
  206.  
  207. GotIt2            move.l    IconBase(a4),a6
  208.             tst.l    DObject(a4)
  209.             beq.s    SkipFreeDD
  210.             move.l    DObject(a4),a0
  211.             CALL    FreeDiskObject
  212.  
  213. SkipFreeDD        move.l    $04,a6
  214.             CALL    CreateMsgPort
  215.             move.l    d0,BrokerPort
  216.             move.l    d0,MyPort(a4)
  217.             move.l    d0,a0
  218.             move.b    MP_SIGBIT(a0),d0
  219.             move.l    SignalMask(a4),d1        ;Enter signal into
  220.             bset    d0,d1            ;mask for waiting
  221.             move.l    d1,SignalMask(a4)
  222.  
  223.             move.l    CommBase(a4),a6
  224.             lea    MyNewBroker(pc),a0
  225.             clr.l    d0
  226.             CALL    CxBroker
  227.             tst.l    d0
  228.             beq    QuitPrg
  229.             move.l    d0,Broker(a4)
  230.  
  231.             move.l    d0,a0
  232.             moveq.l    #1,d0
  233.             CALL    ActivateCxObj
  234.  
  235.             move.l    $04,a6
  236.                     moveq   #-1,d0            ;A Signal for telling
  237.                     jsr     _LVOAllocSignal(a6)    ;our task that sth happened
  238.                     tst.l   d0
  239.                     bmi     Error2
  240.                     move.l  d0,Signal(a4)
  241.             move.l    SignalMask(a4),d1
  242.                     bset    d0,d1
  243.                     move.l    d1,SignalMask(a4)
  244.  
  245.             lea    MyInterrupt(a4),a1
  246.             move.l    #Interrupt3,IS_CODE(a1)
  247.             clr.l    IS_DATA(a1)
  248.             move.b    #NT_INTERRUPT,LN_TYPE(a1)
  249.             move.b    #0,LN_PRI(a1)
  250.             move.l    #HandlerName,LN_NAME(a1)
  251.             move.l    #5,d0    ;INTB_VERTB
  252.             jsr    _LVOAddIntServer(a6)
  253.  
  254.             tst.l    TempCXPOPUP(a4)
  255.             beq.s    WaitOn
  256.             bsr    OpenGUI
  257.  
  258. WaitOn            tst.w    QuitMe(a4)
  259.             bne    QuitPrg
  260.  
  261.             move.l    $04,a6
  262.             move.l    SignalMask(a4),d0        ;Wait for Port and Break
  263.             CALL    Wait
  264.             btst    #SIGBREAKB_CTRL_C,d0    ;This means quit
  265.             bne    QuitPrg
  266.             move.l    Signal(a4),d1
  267.             btst    d1,d0            ;Signal from Interrupt?
  268.             beq.s    TryNextMsg
  269.  
  270.             tst.w    DisableHW(a4)
  271.             bne.s    TryNextMsg        ;Do nothing
  272.  
  273.             move.l    IntBase(a4),a0
  274.             btst    #SignalWindow,What(a4)
  275.             beq.s    NoWindowStuff
  276.             
  277.             move.l    ib_ActiveWindow(a0),a0
  278.             bsr    DoYourJob
  279.             bclr    #SignalWindow,What(a4)
  280.  
  281. NoWindowStuff        btst    #SignalScreen,What(a4)
  282.             beq.s    TryNextMsg
  283.             move.l    IntBase(a4),a0
  284.             move.l    ib_FirstScreen(a0),a0
  285.             bsr    AdjustScreen
  286.             bclr    #SignalScreen,What(a4)
  287.  
  288. TryNextMsg        move.l    MyPort(a4),a0        ;Get the message awaiting
  289.             CALL    GetMsg
  290.             tst.l    d0
  291.             bne.s    GotMsg
  292.             bsr    CheckGUI
  293.             bra    WaitOn
  294.  
  295. GotMsg            move.l    d0,a3
  296.             move.l    d0,a0
  297.             move.l    CommBase(a4),a6
  298.             CALL    CxMsgType
  299.             move.l    d0,d6
  300.             move.l    a3,a0
  301.             CALL    CxMsgID
  302.             move.l    d0,d5
  303.             move.l    a3,a1
  304.             move.l    $04,a6
  305.             CALL    ReplyMsg
  306.             cmp.w    #CXM_IEVENT,d6
  307.             bne.s    OtherCommand
  308.             bsr    OpenGUI
  309.  
  310. OtherCommand        cmp.w    #CXM_COMMAND,d6
  311.             bne    WaitOn
  312.  
  313.             cmp.w    #CXCMD_DISABLE,d5
  314.             bne.s    OtherI1
  315.             move.w    #1,DisableHW(a4)
  316.  
  317. OtherI1            cmp.w    #CXCMD_ENABLE,d5
  318.             bne.s    OtherI2
  319.             clr.w    DisableHW(a4)
  320.  
  321. OtherI2            cmp.w    #CXCMD_UNIQUE,d5
  322.             beq.s    OtherII
  323.             cmp.w    #CXCMD_APPEAR,d5
  324.             bne.s    OtherI3
  325. OtherII            bsr    OpenGUI
  326.  
  327. OtherI3            cmp.w    #CXCMD_DISAPPEAR,d5
  328.             bne.s    OtherI4
  329.             bsr    CloseGUI
  330.  
  331. OtherI4            cmp.w    #CXCMD_KILL,d5
  332.             beq    QuitPrg
  333.  
  334.             bra    TryNextMsg
  335.  
  336. Error2            lea    Text1(pc),a0        ;Seems there is an error
  337.             bsr    OpenRequester        ;in the given arguments
  338.             bra.s    QuitPrg
  339.  
  340. EndeRaus2        lea    Text2(pc),a0        ;Wrong Kickstart
  341.             bsr    PrintText
  342.  
  343. QuitPrg            move.l    RememberStack,a7
  344.             bsr    CloseGUI
  345.             move.l    $04,a6    
  346.             move.l    #5,d0
  347.             lea    MyInterrupt(a4),a1
  348.             tst.l    IS_CODE(a1)
  349.             beq.s    NoHandler
  350.             CALL    RemIntServer        ;Remove the Interrupt-Server
  351.  
  352. NoHandler        tst.l    MyIORequest(a4)
  353.             beq.s    NoDevIO
  354.             move.l    MyIORequest(a4),a1
  355.             CALL    CloseDevice
  356.             move.l    MyIORequest(a4),a0
  357.             CALL    DeleteIORequest    
  358. NoDevIO            tst.l    MouseMsgPort(a4)
  359.             beq.s    NoMouseMsg
  360.  
  361.             move.l    MouseMsgPort(a4),a0
  362.             bsr    CloseMsgPort
  363.  
  364. NoMouseMsg        move.l    Signal(a4),d0        ;Free the signal
  365.             beq.s    DontFreeS
  366.                     CALL    FreeSignal
  367.  
  368. DontFreeS        tst.l    Args(a4)
  369.             beq.s    HmmNoArgs
  370.             move.l    DosBase(a4),a6
  371.             move.l    Args(a4),d1
  372.             CALL    FreeArgs
  373.  
  374. HmmNoArgs        tst.l    Broker(a4)
  375.             beq.s    NoCX
  376.             move.l    CommBase(a4),a6
  377.             move.l    Broker(a4),a0
  378.             CALL    DeleteCxObjAll
  379.  
  380. NoCX            move.l    $04,a6
  381.             tst.l    MyPort(a4)
  382.             beq.s    NoPort
  383.             move.l    MyPort(a4),a0
  384.             bsr    CloseMsgPort
  385.  
  386. NoPort            move.l    IntBase(a4),d0        ;Close librarys
  387.             beq.s    ErrorX2
  388.             move.l    d0,a1
  389.             CALL    CloseLibrary
  390.  
  391. ErrorX2            move.l    GraphicsBase(a4),d0
  392.             beq.s    ErrorX1
  393.             move.l    d0,a1
  394.             CALL    CloseLibrary
  395.  
  396. ErrorX1            move.l    IconBase(a4),d0
  397.             beq.s    NoIconLib
  398.             move.l    d0,a1
  399.             CALL    CloseLibrary
  400.             
  401. NoIconLib        move.l    CommBase(a4),d0
  402.             beq.s    NoCommLib
  403.             move.l    d0,a1
  404.             CALL    CloseLibrary
  405.  
  406. NoCommLib        move.l    GadBase(a4),d0
  407.             beq.s    OnlyDOS
  408.             move.l    d0,a1
  409.             CALL    CloseLibrary
  410.  
  411. OnlyDOS            move.l    DosBase(a4),d0
  412.             beq.s    FreeOnly
  413.             move.l    d0,a1
  414.             CALL    CloseLibrary
  415.  
  416. FreeOnly        move.l    ScreenPatLen(a4),d0
  417.             beq.s    NoScreenPat
  418.             move.l    ScreenPattern(a4),a1
  419.             CALL    FreeMem
  420.  
  421. NoScreenPat        move.l    WindowPatLen(a4),d0
  422.             beq.s    NoWindowPat
  423.             move.l    WindowPattern(a4),a1
  424.             CALL    FreeMem
  425.  
  426. NoWindowPat        move.l    WBMessage(a4),d7
  427.             move.l    a4,a1
  428.             move.l    #AllocLength,d0
  429.             CALL    FreeMem            
  430.  
  431.             move.l    d7,a1
  432.             tst.l    d7
  433.             beq.s    EndeRaus
  434.             CALL    Forbid
  435.             CALL    ReplyMsg
  436.  
  437. EndeRaus        RLoad
  438.             moveq.l    #0,d0
  439.             rts
  440.  
  441. CloseMsgPort        move.l    a0,a3
  442. ClosePortRout        move.l    a3,a0
  443.             CALL    GetMsg
  444.             tst.l    d0
  445.             beq.s    NoMsgLeft
  446.             move.l    d0,a1
  447.             CALL    ReplyMsg
  448.             bra.s    ClosePortRout
  449. NoMsgLeft        move.l    a3,a0
  450.             CALL    DeleteMsgPort        ;and free it
  451.             rts
  452.  
  453.  
  454.             ;Subroutine to print a text to stdout
  455. PrintText        Push    d0-d4/a0-a1/a6
  456.             move.l    a0,a1
  457.             moveq.l    #0,d0
  458. TestLen            tst.b    (a1)+
  459.             beq.s    LaengeOk
  460.             addq    #1,d0
  461.             bra.s    TestLen
  462. LaengeOk        move.l    $04,a6
  463.             lea    DosName(pc),a1
  464.             moveq.l    #0,d0
  465.             CALL    OpenLibrary    
  466.             move.l    d0,DosBase(a4)
  467.             beq    SkipWrite
  468.             move.l    d0,a6
  469.             move.l    a0,d2
  470.             move.l    d0,d3
  471.             CALL    Output
  472.             move.l    d0,d1
  473.             beq.s    SkipWrite
  474.             CALL    Write
  475. SkipWrite        Pull    d0-d4/a0-a1/a6
  476.             rts
  477.  
  478.             ;MainPart: does the scrolling if necessary
  479.             ;Gets window in a0
  480. DoYourJob        RSave
  481.             move.l    a0,d0        ;No Window - let it be!
  482.             beq    LeaveIt
  483.             move.l    a0,a5
  484.  
  485.             move.l    wd_WScreen(a5),a3
  486.             
  487.             move.l    DosBase(a4),a6
  488.  
  489.             tst.b    ScreenPatternMem(a4)
  490.             beq.s    NoMatter2
  491.             move.l    ScreenPattern(a4),d1
  492.             move.l    sc_DefaultTitle(a3),d2
  493.             CALL    MatchPatternNoCase
  494.             beq    LeaveIt
  495.  
  496. NoMatter2        tst.b    WindowPatternMem(a4)
  497.             beq.s    NoMatter3
  498.             move.l    WindowPattern(a4),d1
  499.             move.l    wd_Title(a5),d2
  500.             CALL    MatchPatternNoCase
  501.             beq    LeaveIt
  502.  
  503. NoMatter3        move.l    a3,a0
  504.             move.l    a5,d0
  505.             bsr    RememberWindow
  506. NoInterest        move.l    a0,d0        ;Screen not valid? - let it be!
  507.             beq    LeaveIt
  508.  
  509. NoMatter        move.l    GraphicsBase(a4),a6        ;Get the visible size
  510.             lea    sc_ViewPort(a3),a0    ;of the screen to
  511.             CALL    GetVPModeID        ;determine when a window
  512.             move.l    d0,d2            ;is visible and when not
  513.             lea    DisplayInfer(a4),a1
  514.             move.l    #dim_SIZEOF,d0
  515.             move.l    #DTAG_DIMS,d1
  516.             sub.l    a0,a0
  517.             CALL    GetDisplayInfoData
  518.             lea    DisplayInfer(a4),a0
  519.             lea    dim_TxtOScan(a0),a0
  520.             move.w    ra_MaxX(a0),d0
  521.             sub.w    ra_MinX(a0),d0
  522.             addq    #1,d0
  523.             move.w    d0,VisualX(a4)
  524.  
  525.             move.w    ra_MaxY(a0),d0
  526.             sub.w    ra_MinY(a0),d0
  527.             addq    #1,d0
  528.             move.w    d0,VisualY(a4)
  529.  
  530.             move.l    a3,a0
  531.             move.l    IntBase(a4),a6
  532.             tst.l    TempSFront(a4)        ;do we want screentofront?
  533.             beq.s    NoFront
  534.             CALL    ScreenToFront
  535.             bset    #SignalScreen,What(a4)    ;ScreenChange!
  536.  
  537. NoFront            move.l    wd_Flags(a5),d0
  538.             and.l    #WFLG_BACKDROP,d0
  539.             bne    LeaveIt        ;Not with backdrops!
  540.  
  541.             tst.l    TempWFront(a4)        ;do we WindowToFront() ?
  542.             beq.s    NoFront2
  543.             move.l    a5,a0
  544.             move.l    wd_Flags(a0),d0
  545.             and.l    #WBENCHWINDOW,d0    ;does not work - but why?
  546.             bne.s    NoFront2
  547.             CALL    WindowToFront
  548.  
  549. NoFront2        tst.l    TempMove(a4)
  550.             beq    LeaveIt
  551.             move.l    wd_WScreen(a5),a0    ;If the screen is smaller
  552.             move.w    sc_Width(a0),d0        ;that the visible size
  553.             cmp.w    VisualX(a4),d0        ;in any way, we use the
  554.             bcc.s    NoMat1            ;original screen-size
  555.             move.w    sc_Width(a0),VisualX(a4)
  556. NoMat1            move.w    sc_Height(a0),d0
  557.             cmp.w    VisualY(a4),d0
  558.             bcc.s    NoMat2
  559.             move.w    sc_Height(a0),VisualX(a4)
  560.             
  561.  
  562. NoMat2            moveq.l    #0,d7
  563.             moveq.l    #0,d6
  564.             moveq.l    #0,d0
  565.             moveq.l    #0,d2
  566.             move.w    wd_LeftEdge(a5),d0
  567.             add.w    wd_Width(a5),d0
  568.             move.w    sc_LeftEdge(a0),d2
  569.             neg.w    d2
  570.             add.w    VisualX(a4),d2
  571.             sub.w    d0,d2
  572.             beq.s    SeemsOk2
  573.             bpl.s    SeemsOk
  574.             move.w    d2,d7        ;MOVEX!
  575.             ext.l    d7
  576. SeemsOk            move.w    wd_LeftEdge(a5),d0
  577.             move.w    sc_LeftEdge(a0),d2
  578.             neg.w    d2
  579.             sub.w    d2,d0
  580.             bne.s    TestAgain
  581.             moveq.l    #0,d7
  582. TestAgain        bpl.s    SeemsOk2
  583.             move.w    d0,d7        ;MOVEX!    - Prefer Leftedge
  584.             ext.l    d7
  585.             neg.l    d7
  586. SeemsOk2        move.w    wd_TopEdge(a5),d0
  587.             move.w    sc_TopEdge(a0),d2
  588.             neg.w    d2
  589.             sub.w    d2,d0
  590.             beq.s    SeemsOk4
  591.             bpl.s    SeemsOk3
  592.             move.w    d0,d6
  593.             ext.l    d6        ;MOVEY!
  594.             neg.l    d6
  595. SeemsOk3        move.w    wd_TopEdge(a5),d0
  596.             add.w    wd_Height(a5),d0
  597.             move.w    sc_TopEdge(a0),d2
  598.             neg.w    d2
  599.             add.w    VisualY(a4),d2
  600.             sub.w    d0,d2
  601.             bne.s    TestAgain2
  602.             moveq.l    #0,d6
  603. TestAgain2        bpl.s    SeemsOk4
  604.             move.w    d2,d6        ;MOVEY! - Prefer bottom
  605.             ext.l    d6
  606. SeemsOk4        tst.l    TempAlways(a4)
  607.             bne.s    DOOO
  608.             tst.l    d7
  609.             bne.s    DOOO
  610.             tst.l    d6
  611.             beq    LeaveIt
  612.  
  613. DOOO            move.l    d7,d0
  614.             tst.l    TempAlways(a4)
  615.             bne.s    DoAlways1
  616.             tst.l    d0
  617.             beq.s    NoMoveAny1
  618. DoAlways1        cmp.l    #2,TempHADJ(a4)
  619.             bne.s    NoCentering1
  620.  
  621.             moveq.l    #0,d0
  622.             move.w    wd_Width(a5),d0
  623.             lsr.w    #1,d0
  624.             add.w    wd_LeftEdge(a5),d0
  625.             moveq.l    #0,d2
  626.             move.w    VisualX(a4),d2
  627.             lsr.w    #1,d2
  628.             move.w    sc_LeftEdge(a0),d3
  629.             neg.w    d3
  630.             add.w    d3,d2
  631.             sub.w    d0,d2
  632.             move.l    d2,d0
  633.             ext.l    d0
  634.             bra    NoMoveAny1
  635.             
  636. NoCentering1        tst.l    TempHADJ(a4)
  637.             bne.s    RightAdj
  638.             moveq.l    #0,d0
  639.             move.w    wd_LeftEdge(a5),d0
  640.             add.w    sc_LeftEdge(a0),d0
  641.             neg.w    d0
  642.             ext.l    d0
  643.             bra.s    NoMoveAny1
  644.  
  645. RightAdj        cmp.l    #1,TempHADJ(a4)
  646.             bne.s    NoMoveAny1
  647.             move.w    wd_LeftEdge(a5),d0
  648.             add.w    wd_Width(a5),d0
  649.             move.w    sc_LeftEdge(a0),d2
  650.             neg.w    d2
  651.             add.w    VisualX(a4),d2
  652.             sub.w    d0,d2
  653.             move.l    d2,d0
  654.             ext.l    d0
  655.  
  656. NoMoveAny1        move.l    d6,d1
  657.             tst.l    TempAlways(a4)
  658.             bne.s    DoAlways2
  659.             tst.l    d1
  660.             beq.s    NoMoveAny2
  661. DoAlways2        cmp.l    #2,TempVADJ(a4)
  662.             bne.s    NoCentering2
  663.  
  664.             moveq.l    #0,d1
  665.             move.w    wd_Height(a5),d1
  666.             lsr.w    #1,d1
  667.             add.w    wd_TopEdge(a5),d1
  668.             moveq.l    #0,d2
  669.             move.w    VisualY(a4),d2
  670.             lsr.w    #1,d2
  671.             move.w    sc_TopEdge(a0),d3
  672.             neg.w    d3
  673.             add.w    d3,d2
  674.             sub.w    d1,d2
  675.             move.l    d2,d1
  676.             ext.l    d1
  677.             bra    NoMoveAny2
  678.  
  679. NoCentering2        tst.l    TempVADJ(a4)
  680.             bne.s    BotAdj
  681.             moveq.l    #0,d1
  682.             move.w    wd_TopEdge(a5),d1
  683.             add.w    sc_TopEdge(a0),d1
  684.             neg.w    d1
  685.             ext.l    d1
  686.             bra.s    NoMoveAny2
  687.  
  688. BotAdj            cmp.l    #1,TempVADJ(a4)
  689.             bne.s    NoMoveAny2
  690.             move.w    wd_TopEdge(a5),d1
  691.             add.w    wd_Height(a5),d1
  692.             move.w    sc_TopEdge(a0),d2
  693.             neg.w    d2
  694.             add.w    VisualY(a4),d2
  695.             sub.w    d1,d2
  696.             move.l    d2,d1
  697.             ext.l    d1
  698.  
  699. NoMoveAny2        move.w    sc_TopEdge(a0),d5
  700.             move.w    sc_LeftEdge(a0),d6
  701.             RSave
  702.             CALL    MoveScreen
  703.             RLoad
  704.             sub.w    sc_TopEdge(a0),d5    ;Find out how far the
  705.             sub.w    sc_LeftEdge(a0),d6    ;screen really moves
  706.             move.l    d6,d0
  707.             move.l    d5,d1
  708.             neg.l    d0
  709.             neg.l    d1
  710.  
  711.             tst.l    TempMoveMouse(a4)
  712.             beq.s    LeaveIt
  713.  
  714.             ;If a window becomes active without clicking, the Mouse
  715.             ;can be out of range, and moving it would scroll the
  716.             ;Screen back, so we check this here and disable movement
  717.             ;if "dangerous"
  718.             move.w    ib_MouseX(a6),d2
  719.             add.w    d0,d2    ;Movement in X
  720.             bmi.s    ClearXMovement
  721.             cmp.w    VisualX(a4),d2
  722.             bcs.s    LeaveXMovement
  723. ClearXMovement        moveq.l    #0,d0
  724. LeaveXMovement        move.w    ib_MouseY(a6),d2
  725.             add.w    d1,d2    ;Movement in Y
  726.             bmi.s    ClearYMovement
  727.             cmp.w    VisualY(a4),d2
  728.             bcs.s    LeaveYMoveMent
  729. ClearYMovement        moveq.l    #0,d1
  730. LeaveYMoveMent        bsr    SetPointer
  731. LeaveIt            RLoad
  732.             rts
  733.  
  734.             ;ScreenID in a0
  735. AdjustScreen        RSave
  736.             move.l    a0,a3
  737.             tst.b    ScreenPatternMem(a4)
  738.             beq.s    NoMatter5
  739.             move.l    ScreenPattern(a4),d1
  740.             move.l    sc_DefaultTitle(a3),d2
  741.             move.l    DosBase(a4),a6
  742.             CALL    MatchPatternNoCase
  743.             beq    SkipActive
  744.             move.l    a3,a0
  745.  
  746. NoMatter5        tst.l    TempPDef(a4)    ;Enter FirstScreen as Default
  747.                         ;PublicScreen ?
  748.             beq.s    Skip_NoPub
  749.             bsr    GetPubFromID
  750.             move.l    a0,d0
  751.             beq.s    Skip_NoPub
  752.             move.l    IntBase(a4),a6
  753.             CALL    SetDefaultPubScreen
  754.  
  755. Skip_NoPub        tst.l    TempRemWin(a4)    ;Activate a Window on the new
  756.                         ;Screen?
  757.             beq.s    SkipActive
  758.             bsr    GetScreenWindow
  759.             tst.l    d0
  760.             bne.s    FoundActive
  761.  
  762.             move.l    sc_FirstWindow(a0),d0    ;Take Firstwindow if none
  763.             beq.s    SkipActive        ;known
  764.  
  765. FoundActive        move.l    d0,a5
  766.             tst.b    WindowPatternMem(a4)
  767.             beq.s    NoMatter4
  768.             move.l    WindowPattern(a4),d1
  769.             move.l    wd_Title(a5),d2
  770.             move.l    DosBase(a4),a6
  771.             CALL    MatchPatternNoCase
  772.             beq    SkipActive
  773. NoMatter4        move.l    a5,a0
  774.             move.l    IntBase(a4),a6
  775.             CALL    ActivateWindow
  776. SkipActive        RLoad
  777.             rts
  778.  
  779.         ;a0=Screen         Back:d0=Window
  780. GetScreenWindow        Push    a1/d1
  781.             lea    ScreenMem(a4),a1
  782.             move.w    #MaxScreens-1,d1
  783. ScreenFindLoop        cmp.l    (a1),a0
  784.             beq.s    FoundScreen
  785.             lea    8(a1),a1
  786.             dbf    d1,ScreenFindLoop
  787. FoundScreen        move.l    4(a1),d0
  788.             bsr    TestWindowOnScreen
  789.             Pull    a1/d1
  790.             rts
  791.  
  792.         ;a0=Screen d0=Window
  793. RememberWindow        Push    a1-a3/a6/d1
  794.             move.l    IntBase(a4),a6
  795.             lea    ScreenMem(a4),a1
  796.             move.w    #MaxScreens-1,d1
  797. ScreenFindLoop2        tst.l    (a1)
  798.             beq.s    FoundEmpty
  799.             move.l    (a1),a2
  800.             cmp.l    a0,a2
  801.             beq.s    FoundEmpty    ;because Identical
  802.  
  803.             move.l    ib_FirstScreen(a6),a3
  804. CheckAllScreens        cmp.l    a3,a2
  805.             beq    ScreenValid
  806.             move.l    sc_NextScreen(a3),a3
  807.             cmp.l    #0,a3
  808.             bne.s    CheckAllScreens
  809.             bra.s    FoundEmpty    ;because Entry is invalid
  810.  
  811. ScreenValid        lea    8(a1),a1
  812.             dbf    d1,ScreenFindLoop2
  813.             ;Reaching this Point our List is full of valid
  814.             ;Screens - not the best thing, but we simply ignore...
  815.             bra.s    IgnoreOver
  816. FoundEmpty        move.l    a0,(a1)
  817.             move.l    d0,4(a1)
  818. IgnoreOver        Pull    a1-a3/a6/d1
  819.             rts
  820.  
  821.         ;d0=Window , a0=Screen    =Back: d0=0 no window
  822. TestWindowOnScreen    tst.l    d0
  823.             beq.s    NotWindow
  824.             move.l    sc_FirstWindow(a0),a1
  825. WindowListOn        cmp.l    d0,a1
  826.             beq.s    WindowIsOK
  827.             move.l    wd_NextWindow(a1),a1
  828.             cmp.l    #0,a1
  829.             bne.s    WindowListOn
  830. NotWindow        clr.l    d0
  831.             rts
  832. WindowIsOK        move.l    a1,d0
  833.             rts
  834.  
  835.             ;ScreenID in a0    ;Return a0=PubScreenName or Zero
  836. GetPubFromID        Push    d0/a3/a6
  837.             move.l    a0,a3
  838.             move.l    IntBase(a4),a6
  839.             CALL    LockPubScreenList
  840.  
  841. CarryListOn        move.l    d0,a0
  842.             cmp.l    psn_Screen(a0),a3
  843.             beq.s    ScreenFound
  844.             move.l    LN_SUCC(a0),d0
  845.             bne.s    CarryListOn
  846.             sub.l    a0,a0
  847.             bra.s    ENDPS
  848.  
  849. ScreenFound        move.l    LN_NAME(a0),a0
  850. ENDPS            move.l    a0,-(sp)
  851.             CALL    UnlockPubScreenList
  852.             move.l    (sp)+,a0
  853.             Pull    d0/a3/a6
  854.             rts
  855.  
  856. Interrupt3        RSave
  857.             move.l    RememberA4,a4
  858.             move.l    IntBase(a4),a0
  859.             move.l    Active(a4),d0
  860.             cmp.l    ib_ActiveWindow(a0),d0        ;New ActiveWindow?
  861.             beq.s    DoNothing
  862.             move.l    ib_ActiveWindow(a0),Active(a4)
  863.  
  864.             bsr    SignalMyself
  865.  
  866.             bset    #SignalWindow,What(a4)
  867.             
  868. DoNothing        move.l    IntBase(a4),a0
  869.             move.l    FirstSc(a4),d0
  870.             cmp.l    ib_FirstScreen(a0),d0        ;New FirstScreen?
  871.             beq.s    DoNothing2
  872.             move.l    ib_FirstScreen(a0),FirstSc(a4)
  873.  
  874.             bsr    SignalMyself
  875.  
  876.             bset    #SignalScreen,What(a4)
  877.  
  878. DoNothing2        RLoad
  879.             moveq.l    #0,d0
  880.             rts
  881.  
  882. SignalMyself        move.l  $04,a6
  883.             move.l  OwnTask(a4),a1
  884.             move.l  Signal(a4),d1        ;send a signal to move Screen
  885.             moveq.l    #0,d0
  886.             bset    d1,d0
  887.             CALL    Signal
  888.             rts
  889.  
  890. OpenGUI            RSave
  891.             tst.w    GUIOpened(a4)
  892.             bne    OpenNoGUI
  893.             move.l    IntBase(a4),a6
  894.             sub.l    a0,a0
  895.             CALL    LockPubScreen
  896.             move.l    d0,PublicScreen(a4)
  897.             move.l    d0,StorePublicScreen
  898.  
  899.             move.l    d0,a0
  900.             lea    sc_RastPort(a0),a1
  901.             move.l    a1,PublicRastport(a4)
  902.             lea    TagListDone(pc),a1
  903.             move.l    GadBase(a4),a6
  904.             CALL    GetVisualInfoA
  905.             move.l    d0,MyVisual(a4)
  906.             lea    MyNewGadget(a4),a3
  907.             move.l    d0,gng_VisualInfo(a3)
  908.  
  909.             lea    GadgetList(a4),a0
  910.             CALL    CreateContext
  911.             move.l    d0,Gadget0(a4)
  912.  
  913.             move.l    GraphicsBase(a4),a6
  914.             move.l    PublicRastport(a4),a1
  915.             lea    GUI_Text5(pc),a0
  916.             moveq.l    #GUI_Text6-GUI_Text5-1,d0
  917.             CALL    TextLength
  918.             add.w    #40,d0        ;CheckBox
  919.             lsr.w    #1,d0
  920.             move.w    d0,RemLen(a4)
  921.  
  922.             moveq.l    #1,d0
  923.             add.w    RemLen(a4),d0
  924.             lsl.l    #2,d0
  925.             move.l    d0,StoreInnerWidth
  926.  
  927.             move.l    PublicScreen(a4),a0
  928.             moveq.l    #6,d0
  929.             add.b    sc_WBorLeft(a0),d0
  930.             move.w    d0,RemLeft(a4)
  931.  
  932.             move.l    sc_Font(a0),a1
  933.             move.l    a1,gng_TextAttr(a3)
  934.             moveq.l    #1,d0
  935.             add.b    sc_WBorTop(a0),d0    ;Base (Top)
  936.             move.w    d0,RemTop(a4)
  937.  
  938.             move.w    ta_YSize(a1),d6
  939.             add.w    #4,d6            ;Height of One Line
  940.             move.w    d6,RemHeight(a4)
  941.  
  942.             add.w    #2,d6
  943.             mulu    #9,d6
  944.             add.w    #8,d6
  945.             move.l    d6,StoreInnerHeight
  946.  
  947.             move.l    Gadget0(a4),d7
  948.  
  949.             bsr    DoAllGadgets
  950.  
  951.             move.l    d7,LastGadget(a4)
  952.  
  953.             sub.l    a0,a0
  954.             lea    WindowTagList(pc),a1
  955.             move.l    IntBase(a4),a6
  956.             CALL    OpenWindowTagList
  957.             move.l    d0,MyWindow(a4)
  958.             beq    FailWindow
  959.  
  960.             move.l    d0,a0
  961.             bsr    EnterSignal
  962.             ;move.l    d0,a0
  963.             move.l    GadgetList(a4),a1
  964.             moveq.l    #-1,d0
  965.             moveq.l    #-1,d1
  966.             sub.l    a2,a2
  967.             CALL    AddGList
  968.  
  969.             move.l    GadgetList(a4),a0
  970.             move.l    MyWindow(a4),a1
  971.             moveq.l    #-1,d0
  972.             sub.l    a2,a2
  973.             CALL    RefreshGList
  974.             
  975.             move.l    GadBase(a4),a6
  976.             move.l    MyWindow(a4),a0
  977.             sub.l    a1,a1
  978.             CALL    GT_RefreshWindow
  979.  
  980.             move.w    #1,GUIOpened(a4)
  981.             RLoad
  982.             rts
  983. OpenNoGUI        move.l    IntBase(a4),a6
  984.             move.l    MyWindow(a4),a0
  985.             CALL    ActivateWindow
  986.             RLoad
  987.             rts
  988.  
  989.             rsreset
  990. MyGadgetFlags        rs.l    1
  991. MyGadgetText        rs.l    1
  992. MyGadgetKind        rs.l    1
  993. MyGadgetList        rs.l    1
  994. MyGadgetRowNr        rs.w    1
  995. MyGadgetXPos        rs.w    1
  996. MyGadgetWidth        rs.w    1
  997. MyGadgetStore        rs.w    1
  998. MyGadgetSize        rs.w    1
  999.             
  1000.             ;    gng_Flags      ,gng_Text ,CreateKind   ,CreateTags
  1001.             ;    gng_TopEdge    ,gng_LeftEdge
  1002. AllGadgets        dc.l    PLACETEXT_LEFT,GUI_Text8,CYCLE_KIND,CycleTagList
  1003.             dc.w    1,2,2,TempHADJ
  1004.             dc.l    PLACETEXT_LEFT,GUI_Text9,CYCLE_KIND,CycleTagList2
  1005.             dc.w    2,2,2,TempVADJ
  1006.             dc.l    PLACETEXT_LEFT,GUI_Text12,STRING_KIND,StringTagList
  1007.             dc.w    3,2,2,TempScreen
  1008.             dc.l    PLACETEXT_LEFT,GUI_Text13,STRING_KIND,StringTagList
  1009.             dc.w    4,2,2,TempWindow
  1010.  
  1011.             dc.l    PLACETEXT_RIGHT,GUI_Text1,CHECKBOX_KIND,GadgetTagList
  1012.             dc.w    5,0,2,TempMove
  1013.             dc.l    PLACETEXT_RIGHT,GUI_Text2,CHECKBOX_KIND,GadgetTagList
  1014.             dc.w    5,2,2,TempSFront
  1015.             dc.l    PLACETEXT_RIGHT,GUI_Text3,CHECKBOX_KIND,GadgetTagList
  1016.             dc.w    6,0,2,TempWFront
  1017.             dc.l    PLACETEXT_RIGHT,GUI_Text5,CHECKBOX_KIND,GadgetTagList
  1018.             dc.w    6,2,2,TempPDef
  1019.             dc.l    PLACETEXT_RIGHT,GUI_Text6,CHECKBOX_KIND,GadgetTagList
  1020.             dc.w    7,0,2,TempAlways
  1021.             dc.l    PLACETEXT_RIGHT,GUI_Text7,CHECKBOX_KIND,GadgetTagList
  1022.             dc.w    7,2,2,TempRemWin
  1023.             dc.l    PLACETEXT_RIGHT,GUI_Text7_1,CHECKBOX_KIND,GadgetTagList
  1024.             dc.w    8,0,2,TempMoveMouse
  1025.             dc.l    PLACETEXT_RIGHT,GUI_Text7_2,CHECKBOX_KIND,GadgetTagList
  1026.             dc.w    8,2,2,TempCXPOPUP
  1027.             
  1028.  
  1029.             dc.l    PLACETEXT_IN,GUI_Text10,BUTTON_KIND,TagList
  1030.             dc.w    9,0,1,TempZero
  1031.             dc.l    PLACETEXT_IN,GUI_Text11,BUTTON_KIND,TagList
  1032.             dc.w    9,3,1,TempZero
  1033. SaveGadgData        dc.l    PLACETEXT_IN,GUI_Text14,BUTTON_KIND,TagList
  1034.             dc.w    9,1,1,TempSave
  1035.             dc.l    PLACETEXT_IN,GUI_Text15,BUTTON_KIND,TagList
  1036.             dc.w    9,2,1,TempZero
  1037.  
  1038.  
  1039.             dc.l    -1
  1040.  
  1041.  
  1042.  
  1043. ;a3:Pointer to the GadgetStructure
  1044. ;d7:Previous Gadget
  1045.  
  1046. DoAllGadgets        lea    AllGadgets(pc),a5
  1047.             move.l    GadBase(a4),a6
  1048.             moveq.l    #1,d6
  1049.  
  1050. DoAllGadgets2        tst.l    (a5)
  1051.             bmi.s    WasLastGadget
  1052.  
  1053.             move.w    MyGadgetRowNr(a5),d0
  1054.             move.w    RemHeight(a4),d1
  1055.             addq.w    #2,d1
  1056.             mulu    d1,d0
  1057.             add.w    RemTop(a4),d0    ;Top
  1058.             move.w    d0,gng_TopEdge(a3)
  1059.  
  1060.             move.w    MyGadgetXPos(a5),d0
  1061.             mulu    RemLen(a4),d0
  1062.             add.w    RemLeft(a4),d0
  1063.             move.w    d0,gng_LeftEdge(a3)
  1064.  
  1065.             move.w    MyGadgetWidth(a5),d0
  1066.             mulu    RemLen(a4),d0
  1067.             sub.w    #8,d0
  1068.             move.w    d0,gng_Width(a3)
  1069.  
  1070.             move.w    RemHeight(a4),gng_Height(a3)
  1071.  
  1072.             move.l    MyGadgetFlags(a5),gng_Flags(a3)
  1073.             add.w    #1,gng_GadgetID(a3)
  1074.  
  1075.             move.l    MyGadgetText(a5),gng_GadgetText(a3)
  1076.  
  1077.             move.w    d6,gng_GadgetID(a3)
  1078.  
  1079.             sub.l    a2,a2
  1080.             move.w    MyGadgetStore(a5),a2
  1081.             add.l    a4,a2
  1082.             move.l    (a2),d4
  1083.  
  1084.             move.l    MyGadgetKind(a5),d0
  1085.             move.l    d7,a0        ;Previous Gadget
  1086.             move.l    a3,a1
  1087.             move.l    MyGadgetList(a5),a2
  1088.             move.l    d4,4(a2)
  1089.             CALL    CreateGadgetA
  1090.             move.l    d0,d7        ;Remember Previous Gadget
  1091.             add.l    #MyGadgetSize,a5
  1092.             addq.l    #1,d6
  1093.             bra.s    DoAllGadgets2
  1094. WasLastGadget        rts
  1095.  
  1096. CheckGUI        RSave
  1097.  
  1098.             tst.w    GUIOpened(a4)
  1099.             beq    NoGUI
  1100.  
  1101.             move.l    GadBase(a4),a6
  1102.             move.l    MyWindow(a4),a0
  1103.             move.l  wd_UserPort(a0),a0
  1104.             CALL    GT_GetIMsg
  1105.             tst.l   d0         
  1106.             beq     NoGUI
  1107.             move.l  d0,a1
  1108.             moveq.l    #0,d6
  1109.             move.w    im_Code(a1),d6    ;Value of Gadget
  1110.             move.l  im_IAddress(a1),a2
  1111.  
  1112.             move.l    im_Class(a1),d7
  1113.             CALL    GT_ReplyIMsg
  1114.  
  1115.             cmp.l    #GADGETUP,d7
  1116.             bne.s    Others
  1117.  
  1118.             move.w    gg_GadgetID(a2),d0
  1119.             move.l    gg_SpecialInfo(a2),a3
  1120.             cmp.w    #13,d0
  1121.             beq    HideGad
  1122.             cmp.w    #14,d0
  1123.             beq    QuitGad
  1124.             cmp.w    #15,d0
  1125.             beq    SaveGad
  1126.             cmp.w    #16,d0
  1127.             beq    AboutGad
  1128.  
  1129.             subq.l    #1,d0
  1130.  
  1131.             lea    AllGadgets(pc),a5
  1132.             mulu    #MyGadgetSize,d0
  1133.             sub.l    a2,a2
  1134.             move.w    MyGadgetStore(a5,d0.w),a2
  1135.             add.l    a4,a2
  1136.  
  1137.             cmp.l    #STRING_KIND,MyGadgetKind(a5,d0.w)
  1138.             bne.s    StandardGUI
  1139.             move.l    si_Buffer(a3),a0
  1140.             move.l    (a2),a1
  1141.             bsr    CopyPattern
  1142.             bsr    BuildPatterns
  1143.             bra.s    NoGUI
  1144.  
  1145. StandardGUI        move.l    d6,(a2)
  1146.             bra.s    NoGUI
  1147.  
  1148. SaveGad            bsr    SaveConfig
  1149.             bra.s    NoGUI
  1150.  
  1151. AboutGad        lea    AboutText(pc),a0
  1152.             bsr    OpenRequester
  1153.             bra.s    NoGUI
  1154.  
  1155. QuitGad            bsr    CloseGUI
  1156.             move.w    #1,QuitMe(a4)
  1157.             bra.s    HideGad
  1158.  
  1159. Others                    cmp.l   #CLOSEWINDOW,d7
  1160.                     bne.s    NoGUI
  1161. HideGad            bsr    CloseGUI
  1162. NoGUI            RLoad
  1163.             rts
  1164.  
  1165. CloseGUI        RSave
  1166.             tst.w    GUIOpened(a4)
  1167.             beq.s    NotOpened
  1168.             move.l    IntBase(a4),a6
  1169.             move.l    MyWindow(a4),a0
  1170.             bsr    RemoveSignal
  1171.             ;move.l    MyWindow(a4),a0
  1172.             move.l    GadgetList(a4),a1
  1173.             moveq.l    #-1,d0
  1174.             CALL    RemoveGList
  1175.  
  1176.             move.l    MyWindow(a4),a0
  1177.             clr.l    d0
  1178.             move.w    wd_TopEdge(a0),d0
  1179.             move.l    d0,RemWindowY
  1180.             move.w    wd_LeftEdge(a0),d0
  1181.             move.l    d0,RemWindowX
  1182.             CALL    CloseWindow
  1183.             
  1184. FailWindow        move.l    GadgetList(a4),a0
  1185.             move.l    GadBase(a4),a6
  1186.             CALL    FreeGadgets
  1187.  
  1188.             move.l    MyVisual(a4),a0
  1189.             CALL    FreeVisualInfo
  1190.  
  1191.             move.l    IntBase(a4),a6
  1192.             sub.l    a0,a0
  1193.             move.l    PublicScreen(a4),a1
  1194.             CALL    UnlockPubScreen
  1195.  
  1196. NotOpened        clr.w    GUIOpened(a4)
  1197.  
  1198.             RLoad
  1199.             rts
  1200.  
  1201. EnterSignal        Push    d0-d1/a0          
  1202.             move.l  wd_UserPort(a0),a0
  1203.             move.b  MP_SIGBIT(a0),d0  
  1204.             move.l    SignalMask(a4),d1
  1205.             bset    d0,d1             
  1206.             move.l  d1,SignalMask(a4) 
  1207.             Pull    d0-d1/a0          
  1208.             rts                       
  1209.                                           
  1210. RemoveSignal        Push    d0-d1/a0          
  1211.             move.l  wd_UserPort(a0),a0
  1212.             move.b  MP_SIGBIT(a0),d0
  1213.             move.l    SignalMask(a4),d1
  1214.             bclr    d0,d1             
  1215.             move.l    d1,SignalMask(a4) 
  1216.             Pull    d0-d1/a0          
  1217.             rts
  1218.  
  1219. GetNexta0        move.b    (a0)+,d0
  1220.             cmp.b    #"=",d0
  1221.             beq.s    GetNexta0
  1222.             cmp.b    #" ",d0
  1223.             beq.s    GetNexta0
  1224.             or.w    #$20,d0
  1225.             rts
  1226.  
  1227. ;Screen in a0, X-Coord(rel) in d0, Y-Coord(rel) in d1
  1228. SetPointer        Push    a0-a2/d0-d1/a6
  1229.             lea    PointerPixEvent(a4),a2
  1230.             move.l    a0,iepp_Screen(a2)
  1231.             move.w    d0,iepp_PositionX(a2)
  1232.             move.w    d1,iepp_PositionY(a2)
  1233.  
  1234.             move.l    MyIORequest(a4),a1
  1235.             move.w    #IND_WRITEEVENT,io_Command(a1)
  1236.             lea    MyInputEvent(a4),a0
  1237.             move.l    #0,ie_NextEvent(a0)
  1238.             move.b    #IECLASS_NEWPOINTERPOS,ie_Class(a0)
  1239.             move.b    #IESUBCLASS_PIXEL,ie_SubClass(a0)
  1240.             move.w    #IECODE_NOBUTTON,ie_Code(a0)
  1241.             move.w    #IEQUALIFIER_RELATIVEMOUSE,ie_Qualifier(a0)
  1242.             move.l    a2,ie_EventAddress(a0)
  1243.             move.l    a0,io_Data(a1)
  1244.             move.l    #ie_SIZEOF,io_Length(a1)
  1245.             move.l    $04,a6
  1246.             CALL    DoIO
  1247.             Pull    a0-a2/a6/d0-d1
  1248.             rts
  1249.  
  1250. BuildPatterns        RSave
  1251.             tst.l    TempScreen(a4)
  1252.             beq.s    NoScreenPattern
  1253.             move.l    TempScreen(a4),a0
  1254.             lea    ScreenPatternMem(a4),a1
  1255.             bsr    CopyPattern
  1256.  
  1257.             lea    ScreenPatternMem(a4),a0
  1258.             lea    ScreenPatLen(a4),a2
  1259.             lea    ScreenPattern(a4),a3
  1260.             bsr    GetLen
  1261.             bpl    NoScreenPattern
  1262.             bsr    PatternError
  1263.  
  1264. NoScreenPattern        lea    ScreenPatternMem(a4),a0
  1265.             move.l    a0,TempScreen(a4)
  1266.             tst.l    TempWindow(a4)
  1267.             beq.s    NoWindowPattern
  1268.             move.l    TempWindow(a4),a0
  1269.             lea    WindowPatternMem(a4),a1
  1270.             bsr    CopyPattern
  1271.  
  1272.             lea    WindowPatternMem(a4),a0
  1273.             lea    WindowPatLen(a4),a2
  1274.             lea    WindowPattern(a4),a3
  1275.             bsr    GetLen
  1276.             bpl.s    NoWindowPattern
  1277.             bsr    PatternError
  1278.     
  1279. NoWindowPattern        lea    WindowPatternMem(a4),a0
  1280.             move.l    a0,TempWindow(a4)
  1281.             RLoad
  1282.             rts        
  1283.  
  1284. PatternError        lea    Text3(pc),a0
  1285.             bra    OpenRequester
  1286.  
  1287. CopyPattern        move.w    #511,d0
  1288. DoCopy            move.b    (a0)+,(a1)+
  1289.             beq.s    EndCopy
  1290.             dbf    d0,DoCopy
  1291.             bsr    PatternError
  1292. EndCopy            rts
  1293.  
  1294.  
  1295. ;In: (a2): LEN - (a3): MEMORY - a0: Source-Pattern    :back: d0=pattern ok?
  1296. GetLen            move.l    a0,d6
  1297.             clr.l    d3
  1298. GetLen2            tst.b    (a0)+
  1299.             beq.s    EndOfString
  1300.             addq.l    #1,d3
  1301.             bra.s    GetLen2
  1302. EndOfString        lsl.w    #1,d3    ;StandardLen Of Pattern
  1303.             addq    #2,d3
  1304.             move.l    $04,a6
  1305.             tst.l    (a3)
  1306.             beq    AllocNew
  1307.             move.l    (a3),a1
  1308.             move.l    (a2),d0
  1309.             CALL    FreeMem
  1310.             clr.l    (a3)
  1311. AllocNew        move.l    d3,(a2)
  1312.             move.l    d3,d0
  1313.             move.l    #MEMF_CLEAR,d1
  1314.             CALL    AllocMem
  1315.             move.l    d0,d2
  1316.             beq    QuitPrg        ;No Memory? Good bye !
  1317.             move.l    d0,(a3)
  1318.             move.l    d6,d1
  1319.             move.l    DosBase(a4),a6
  1320.             CALL    ParsePatternNoCase
  1321.             rts
  1322.  
  1323.             
  1324. ;a0: Requester-Text
  1325. OpenRequester        Push    a0-a3
  1326.             lea    EasyReqStruct(a4),a1
  1327.             lea    PortName(pc),a2
  1328.             move.l    a2,es_Title(a1)
  1329.             move.l    a0,es_TextFormat(a1)
  1330.             lea    GadgetText(pc),a2
  1331.             move.l    a2,es_GadgetFormat(a1)
  1332.             move.l    IntBase(a4),a6
  1333.             sub.l    a0,a0
  1334.             ;a1: EasyReq
  1335.             sub.l    a2,a2
  1336.             sub.l    a3,a3
  1337.             CALL    EasyRequestArgs
  1338.             Pull    a0-a3
  1339.             rts
  1340.  
  1341. SaveConfig        RSave
  1342.             tst.l    WBMessage(a4)
  1343.             beq    SkipConfig
  1344.             move.l    WBMessage(a4),a3
  1345.             move.l    sm_ArgList(a3),d0
  1346.             beq    SkipConfig
  1347.             move.l    d0,a0
  1348.  
  1349.             move.l    IconBase(a4),a6
  1350.             move.l    wa_Name(a0),a0
  1351.             move.l    a0,d5
  1352.             CALL    GetDiskObject
  1353.             move.l    d0,DObject(a4)
  1354.             beq    SkipConfig
  1355.  
  1356.             move.l    d0,a0
  1357.             move.l    do_ToolTypes(a0),a5    ;Remember Old
  1358.             move.l    #1,TempDummy(a4)
  1359.  
  1360.             Push    a0/a6
  1361.             move.l    $04,a6
  1362.             move.l    #NumberOfTemps*10+2*512+2*8,d0    ;Memory for tool arrays
  1363.             move.l    #MEMF_CLEAR,d1
  1364.             CALL    AllocMem
  1365.             move.l    d0,a3
  1366.             beq    MemErrTool
  1367.             move.l    DObject(a4),a0
  1368.             move.l    d0,do_ToolTypes(a0)
  1369.  
  1370.             move.l    d0,a1
  1371.             add.l    #(NumberOfTemps+1)*4,a1    ;Maximum Number of Pointers
  1372.  
  1373.             clr.l    d7
  1374.             lea    WBTemplate(pc),a2
  1375. LoopAllTemps        sub.l    a0,a0
  1376.             move.w    TemplateA4(a2),a0
  1377.             add.l    a4,a0
  1378.             move.l    (a0),d6
  1379.             beq.s    IsDefault
  1380.             move.l    a1,(a3,d7)
  1381.             move.l    TemplateText(a2),a0
  1382.             bsr    CopyPattern
  1383.             move.w    TemplateType(a2),d1
  1384.             beq    ThatsAllTemp
  1385.             move.b    #"=",-1(a1)
  1386.             
  1387.             cmp.w    #T_CYCLE,d1
  1388.             bne.s    ThatsString
  1389.             move.l    TemplateSpecial(a2),a0
  1390.             lsl.l    #2,d6
  1391.             move.l    (a0,d6.w),a0
  1392.             bsr    CopyPattern
  1393.             bra.s    ThatsAllTemp
  1394.  
  1395. ThatsString        move.l    d6,a0
  1396.             bsr    CopyPattern
  1397.  
  1398. ThatsAllTemp        addq.l    #4,d7
  1399.             move.l    a1,d0
  1400.             and.l    #$ffffffc,d0
  1401.             move.l    d0,a1
  1402.             lea    4(a1),a1    ;Align on Longwords
  1403. IsDefault        add.l    #TemplateSize,a2
  1404.             tst.l    TemplateText(a2)
  1405.             bne    LoopAllTemps
  1406.  
  1407.             move.l    d5,a0
  1408.             move.l    DObject(a4),a1
  1409.             move.l    IconBase(a4),a6
  1410.             CALL    PutDiskObject
  1411.             bne.s    Done
  1412.             lea    Text4(pc),a0
  1413.             bsr    OpenRequester
  1414.  
  1415. Done            move.l    $04,a6
  1416.             move.l    #NumberOfTemps*10+2*512+2*8,d0
  1417.             move.l    a3,a1
  1418.             CALL    FreeMem
  1419. MemErrTool        Pull    a0/a6
  1420.  
  1421.             move.l    a5,do_ToolTypes(a0)
  1422.             move.l    DObject(a4),a0
  1423.             CALL    FreeDiskObject
  1424.                 
  1425.             bra.s    DoneConfig
  1426.  
  1427. SkipConfig        lea    Text4(pc),a0
  1428.             bsr    OpenRequester
  1429. DoneConfig        RLoad
  1430.             rts
  1431.  
  1432.  
  1433.         ;GetDiskObject(Name)
  1434.  
  1435.  
  1436. StringTagList        dc.l    GTST_String
  1437.             dc.l    0
  1438.             dc.l    GTST_MaxChars
  1439.             dc.l    511
  1440.             dc.l    TAG_DONE
  1441.  
  1442. CycleTagList        dc.l    GTCY_Active
  1443.             dc.l    0
  1444.             dc.l    GTCY_Labels
  1445.             dc.l    CycleList
  1446.             dc.l    TAG_DONE
  1447.  
  1448. CycleTagList2        dc.l    GTCY_Active
  1449.             dc.l    0
  1450.             dc.l    GTCY_Labels
  1451.             dc.l    CycleList2
  1452.             dc.l    TAG_DONE
  1453.  
  1454. GadgetTagList        dc.l    GTCB_Checked
  1455.             dc.l    0
  1456.             dc.l    TAG_DONE
  1457.  
  1458. TagList            dc.l    GA_Disabled
  1459.             dc.l    0
  1460. TagListDone        dc.l    TAG_DONE
  1461.  
  1462. WindowTagList        dc.l    WA_InnerWidth
  1463. StoreInnerWidth            dc.l    0
  1464.             dc.l    WA_InnerHeight
  1465. StoreInnerHeight        dc.l    0
  1466.             dc.l    WA_IDCMP
  1467.                 dc.l    BUTTONIDCMP!CLOSEWINDOW
  1468.             dc.l    WA_Flags
  1469.                 dc.l    WINDOWCLOSE!WINDOWDRAG!WINDOWDEPTH!ACTIVATE    
  1470.             dc.l    WA_PubScreen
  1471. StorePublicScreen        dc.l    0
  1472.             dc.l    WA_Title
  1473.                 dc.l    Texth
  1474.             dc.l    WA_AutoAdjust
  1475.                 dc.l    1
  1476.             dc.l    WA_Left
  1477. RemWindowX            dc.l    -1
  1478.             dc.l    WA_Top
  1479. RemWindowY            dc.l    -1
  1480.             dc.l    TAG_DONE
  1481. RememberA4        dc.l    0
  1482. RememberStack        dc.l    0
  1483.  
  1484.             rsreset
  1485.  
  1486. DisplayInfer        rs.b    dim_SIZEOF
  1487. ScreenPatLen        rs.l    1
  1488. ScreenPattern        rs.l    1
  1489. WindowPatLen        rs.l    1
  1490. WindowPattern        rs.l    1
  1491. GadgetList        rs.l    1
  1492. What            rs.w    1
  1493. DisableHW        rs.w    1
  1494. GUIOpened        rs.w    1
  1495. QuitMe            rs.w    1
  1496. RemFontSize        rs.w    1
  1497. GadgetInside        rs.w    11
  1498. MyPort            rs.l    1
  1499. MyVisual        rs.l    1
  1500. Broker            rs.l    1
  1501. ScreenMem        rs.b    ScreenMemSize
  1502. IntBase            rs.l    1
  1503. RemLen            rs.w    1
  1504. RemHeight        rs.w    1
  1505. RemTop            rs.w    1
  1506. RemLeft            rs.w    1
  1507.  
  1508. GadBase            rs.l    1
  1509. DosBase            rs.l    1
  1510. CommBase        rs.l    1
  1511. IconBase        rs.l    1
  1512. DObject            rs.l    1
  1513. Active            rs.l    1
  1514. FirstSc            rs.l    1
  1515. GraphicsBase        rs.l    1
  1516. PublicScreen        rs.l    1
  1517. PublicRastport        rs.l    1
  1518. Gadget0            rs.l    1
  1519. VisualX            rs.w    1
  1520. VisualY            rs.w    1
  1521. TemplateArray        rs.l    0    ;Do not change order!
  1522. TempMove        rs.l    1
  1523. TempSFront        rs.l    1
  1524. TempWFront        rs.l    1
  1525. TempPDef        rs.l    1
  1526. TempAlways        rs.l    1
  1527. TempRemWin        rs.l    1
  1528. TempMoveMouse        rs.l    1
  1529. TempCXPOPUP        rs.l    1
  1530. TempHADJ        rs.l    1
  1531. TempVADJ        rs.l    1
  1532. TempScreen        rs.l    1
  1533. TempWindow        rs.l    1
  1534. TempDummy        rs.l    1
  1535. TempZero        rs.l    1
  1536. TempSave        rs.l    1
  1537.  
  1538. OwnTask            rs.l    1
  1539. Signal            rs.l    1
  1540. Args            rs.l    1
  1541. WBMessage        rs.l    1
  1542. SignalMask        rs.l    1
  1543. MyWindow        rs.l    1
  1544. LastGadget        rs.l    1
  1545. MyIORequest        rs.l    1
  1546. MouseMsgPort        rs.l    1
  1547. MyNewGadget        rs.b    gng_SIZEOF
  1548. MyInterrupt        rs.b    IS_SIZE
  1549. MyInputEvent        rs.b    ie_SIZEOF
  1550. PointerPixEvent        rs.b    IEPointerPixel_SIZEOF
  1551. EasyReqStruct        rs.b    es_SIZEOF
  1552. ScreenPatternMem    rs.b    512    ;sufficient I think
  1553. WindowPatternMem    rs.b    512
  1554. AllocLength        rs.w    1
  1555.  
  1556. intuition        dc.b    "intuition.library",0
  1557. DosName            dc.b    "dos.library",0
  1558. InputName        dc.b    "input.device",0
  1559. GraphicsName        dc.b    "graphics.library",0
  1560. IconName        dc.b    "icon.library",0
  1561. GadName            dc.b    "gadtools.library",0
  1562. CommName        dc.b    "commodities.library",0
  1563.             even
  1564.  
  1565. MyNewBroker        dc.b    NB_VERSION    ;Version
  1566.             dc.b    0        ;Reserve1
  1567.             dc.l    HandlerName    ;Name
  1568.             dc.l    PortName    ;Title
  1569.             dc.l    DescText    ;Description
  1570.             dc.w    NBU_NOTIFY!NBU_UNIQUE        ;Unique
  1571.             dc.w    COF_SHOW_HIDE    ;Flags
  1572.             dc.b    0        ;Pri
  1573.             dc.b    0        ;Reserve2
  1574. BrokerPort        dc.l    0        ;Port
  1575.             dc.w    0        ;ReservedChannel
  1576.  
  1577. CycleList    dc.l    GUI_Choose1.1,GUI_Choose1.2,GUI_Choose1.3,GUI_Choose1.4,0
  1578. CycleList2    dc.l    GUI_Choose2.1,GUI_Choose2.2,GUI_Choose2.3,GUI_Choose2.4,0
  1579.  
  1580.         rsreset
  1581. TemplateText    rs.l    1
  1582. TemplateSpecial    rs.l    1
  1583. TemplateA4    rs.w    1
  1584. TemplateType    rs.w    1
  1585. TemplateSize    rs.w    0
  1586.  
  1587. T_CHECK        =    0
  1588. T_CYCLE        =    1
  1589. T_STRING    =    2
  1590.  
  1591. NumberOfTemps    =    12
  1592.  
  1593. WBTemplate    dc.l    TextDNW,0
  1594.         dc.w    TempDummy,T_CHECK
  1595.  
  1596.         dc.l    TextMove,0
  1597.         dc.w    TempMove,T_CHECK
  1598.  
  1599.         dc.l    TextSFront,0
  1600.         dc.w    TempSFront,T_CHECK
  1601.  
  1602.         dc.l    TextWFront,0
  1603.         dc.w    TempWFront,T_CHECK
  1604.  
  1605.         dc.l    TextPDef,0
  1606.         dc.w    TempPDef,T_CHECK
  1607.  
  1608.         dc.l    TextAlways,0
  1609.         dc.w    TempAlways,T_CHECK
  1610.  
  1611.         dc.l    TextRemWin,0
  1612.         dc.w    TempRemWin,T_CHECK
  1613.  
  1614.         dc.l    TextMoveMouse,0
  1615.         dc.w    TempMoveMouse,T_CHECK
  1616.  
  1617.         dc.l    TextCXPOPUP,0
  1618.         dc.w    TempCXPOPUP,T_CHECK
  1619.  
  1620.         dc.l    TextScreen,0
  1621.         dc.w    TempScreen,T_STRING
  1622.  
  1623.         dc.l    TextWindow,0
  1624.         dc.w    TempWindow,T_STRING
  1625.  
  1626.         dc.l    TextHADJ,CycleList
  1627.         dc.w    TempHADJ,T_CYCLE
  1628.  
  1629.         dc.l    TextVADJ,CycleList2
  1630.         dc.w    TempVADJ,T_CYCLE
  1631.  
  1632.         dc.l    0
  1633.  
  1634.  
  1635. TextDNW        dc.b    "DONOTWAIT",0
  1636. TextMove    dc.b    "MOVE",0
  1637. TextSFront    dc.b    "SFRONT",0
  1638. TextWFront    dc.b    "WFRONT",0
  1639. TextPDef    dc.b    "DEFPUB",0
  1640. TextAlways    dc.b    "ALWAYS",0
  1641. TextCXPOPUP    dc.b    "CX_POPUP",0
  1642. TextRemWin    dc.b    "REMWIN",0
  1643. TextMoveMouse    dc.b    "MOVEMOUSE",0
  1644. TextHADJ    dc.b    "HADJ",0
  1645. TextVADJ    dc.b    "VADJ",0
  1646. TextScreen    dc.b    "SCREEN",0
  1647. TextWindow    dc.b    "WINDOW",0
  1648. Template    dc.b    "MOVE/S,SFRONT/S,WFRONT/S,DEFPUB/S,ALWAYS/S,REMWIN/S,MOVEMOUSE/S,CX_POPUP/S,HADJ/K,VADJ/K,SCREEN/K,WINDOW/K",0
  1649. PortName    dc.b    "Huntwindows 2.4",0
  1650. HandlerName    dc.b    "Huntwindows",0
  1651. GadgetText    dc.b    "Ok",0
  1652. AboutText    dc.b    "© by Jörg Bublath 1992-1993",$0a,"EMAIL:",$0a,"bublath@forwiss.uni-passau.de",0
  1653. Text1        dc.b    "Error in arguments or libraries!",$0a,0
  1654. Text2        dc.b    "I need V36+ !",$0a,0
  1655. Text3        dc.b    "Error in given patterns!",$0a,0
  1656. Text4        dc.b    "Cannot Save!",$0a,0
  1657.         dc.b    "$VER: "    ;for version information
  1658. Texth        dc.b    "Huntwindows 2.4 (31.3.93) by Jörg Bublath",0
  1659. DescText    dc.b    "Moves screen to show windows",0
  1660. GUI_Text1    dc.b    "Move Screen",0
  1661. GUI_Text2    dc.b    "ScreenToFront",0
  1662. GUI_Text3    dc.b    "WindowToFront",0
  1663. GUI_Text5    dc.b    "Set Default PubScreen",0
  1664. GUI_Text6    dc.b    "Always",0
  1665. GUI_Text7    dc.b    "Remember Window",0
  1666. GUI_Text7_1    dc.b    "Move Mouse",0
  1667. GUI_Text7_2    dc.b    "GUI Popup",0
  1668. GUI_Text8    dc.b    "Horizontal Adjustment",0
  1669. GUI_Text9    dc.b    "Vertical Adjustment",0
  1670. GUI_Text10    dc.b    "Hide",0
  1671. GUI_Text11    dc.b    "Quit",0
  1672. GUI_Text12    dc.b    "Screen Pattern",0
  1673. GUI_Text13    dc.b    "Window Pattern",0
  1674. GUI_Text14    dc.b    "Save",0
  1675. GUI_Text15    dc.b    "About",0
  1676. GUI_TextEnd    ;
  1677. GUI_Choose1.1    dc.b    "left",0
  1678. GUI_Choose1.2    dc.b    "right",0
  1679. GUI_Choose1.3    dc.b    "center",0
  1680. GUI_Choose1.4    dc.b    "off",0
  1681. GUI_Choose2.1    dc.b    "top",0
  1682. GUI_Choose2.2    dc.b    "bottom",0
  1683. GUI_Choose2.3    dc.b    "center",0
  1684. GUI_Choose2.4    dc.b    "off",0
  1685.         even
  1686.